import java.util.Scanner;

/**
 * @author ShenTuZhiGang
 * @version 1.0.0
 * @email 1600337300@qq.com
 * @date 2021-09-26 19:52
 */
public class ExamTencent2021092601 {
    public static void main(String[] args) {
        Prime prime = new Prime(200000);
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- != 0) {
            int x = scanner.nextInt();
            long l = prime.get(x + 1);
            System.out.println(l * prime.get(l + x));
        }
    }
}

class Prime {
    private final boolean[] p;
    private final long[] prime;
    private int len = 0;

    Prime(int n) {
        p = new boolean[n];
        prime = new long[n];
        for (int i = 2; i < n; ++i) {
            if (!p[i]) {
                prime[len++] = i;
                for (int j = i + i; j < n; j += i) {
                    p[j] = true;
                }
            }
        }
    }

    public long get(long n) {
        for (int i = 0; i < n; ++i) {
            if (prime[i] >= n) {
                return prime[i];
            }
        }
        return -1;
    }
}